package com.ruoyi.web.controller.mdm;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mdm.domain.SkuMergeMasterSub;
import com.ruoyi.mdm.service.ISkuMergeMasterSubService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * skum子Controller
 *
 * @author shiseido
 * @date 2025-03-01
 */
@RestController
@RequestMapping("/mdm/skuMergeMasterSub")
public class SkuMergeMasterSubController extends BaseController {
    @Autowired
    private ISkuMergeMasterSubService skuMergeMasterSubService;

    /**
     * 查询skum子列表
     */
    @ApiOperation("查询skum关联列表")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:list')")
    @GetMapping("/list")
    public TableDataInfo list(SkuMergeMasterSub skuMergeMasterSub) {
        startPage();
        List<SkuMergeMasterSub> list = skuMergeMasterSubService.selectSkuMergeMasterSubList(skuMergeMasterSub);
        return getDataTable(list);
    }

    /**
     * 导出skum子列表
     */
    @ApiOperation("导出skum关联列表")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:export')")
    @Log(title = "SKUM关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SkuMergeMasterSub skuMergeMasterSub) {
        List<SkuMergeMasterSub> list = skuMergeMasterSubService.selectSkuMergeMasterSubList(skuMergeMasterSub);
        ExcelUtil<SkuMergeMasterSub> util = new ExcelUtil<SkuMergeMasterSub>(SkuMergeMasterSub.class);
        util.exportExcel(response, list, "skum子数据");
    }

    /**
     * 获取skum子详细信息
     */
    @ApiOperation("获取skum关联详细信息")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(skuMergeMasterSubService.selectSkuMergeMasterSubById(id));
    }

    /**
     * 新增skum子
     */
    @ApiOperation("新增skum关联")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:add')")
    @Log(title = "SKUM关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SkuMergeMasterSub skuMergeMasterSub) {
        return toAjax(skuMergeMasterSubService.insertSkuMergeMasterSub(skuMergeMasterSub));
    }

    /**
     * 修改skum子
     */
    @ApiOperation("修改skum关联")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:edit')")
    @Log(title = "SKUM关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SkuMergeMasterSub skuMergeMasterSub) {
        return toAjax(skuMergeMasterSubService.updateSkuMergeMasterSub(skuMergeMasterSub));
    }

    /**
     * 删除skum子
     */
    @ApiOperation("删除skum关联")
    @PreAuthorize("@ss.hasPermi('mdm:skuMergeMasterSub:remove')")
    @Log(title = "SKUM关联", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(skuMergeMasterSubService.deleteSkuMergeMasterSubByIds(ids));
    }
}
